﻿using System;
using System.ComponentModel;

namespace Jerry.DroidBuilder.Resource
{
    [AttributeUsage(AttributeTargets.Property)]
    public class SRCategoryAttribute : CategoryAttribute
    {
        private const string CATEGORY_PROFIX = "Category_";

        /// <summary>
        /// Initializes a new instance of <see cref="SRCategoryAttribute"/>.
        /// </summary>
        public SRCategoryAttribute()
        {

        }

        /// <summary>
        /// Initializes a new instance of <see cref="SRCategoryAttribute"/>.
        /// </summary>
        public SRCategoryAttribute(string category)
            : base(category)
        {

        }

        protected override string GetLocalizedString(string value)
        {
            string result = SR.GetString(CATEGORY_PROFIX + value);

            if (!string.IsNullOrEmpty(result))
            {
                return result;
            }

            return base.GetLocalizedString(value);
        }
    }
}
